﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConceptsFramework.AbstractConceptElements;

namespace ConceptsFramework.Containers.Global
{
    public class RelationshipsGroup
    {
        public Dictionary<string, AbstractRelationship> RelationshipFlatContainer;

        /// <summary>
        /// Metadata is some information used while processing the relationshipsGroup 
        /// cluster analysis
        /// </summary>
        protected string MetaData
        {
            get; set;
        }

        /// <summary>
        /// The same information as the current _container (copied information), 
        /// but organized in clusters.
        /// </summary>
        public List<RelationshipsGroup> Clusters; 

        public RelationshipsGroup()
        {
            RelationshipFlatContainer = new Dictionary<string, AbstractRelationship>();
            Clusters = new List<RelationshipsGroup>();
        }

        public void Add(AbstractRelationship aRelationShip)
        {
            if (!RelationshipFlatContainer.ContainsKey(aRelationShip.ID))
                RelationshipFlatContainer.Add(aRelationShip.ID, aRelationShip);
        }

        
        public AbstractRelationship GetRelationship(string strRelationshipKey)
        {
            return RelationshipFlatContainer[strRelationshipKey];
        }

        public List<AbstractRelationship> GetRelationships(List<string> relationshipsKey)
        {
            List<AbstractRelationship> rtnGroup = new List<AbstractRelationship>();
            foreach (string strRelationshipKey in relationshipsKey)
            {
                if (RelationshipFlatContainer.ContainsKey(strRelationshipKey))
                {
                    rtnGroup.Add(RelationshipFlatContainer[strRelationshipKey]);
                }
            }
            return rtnGroup;
        }

    }
}
